# Change this to em64t for x86_64. Leave this at ia32 for 32-bit builds
IPPARCH=ia32
CCMODE=-m32
CC=cc
# FSBASE means your base directory where FreeSwitch is installed. No need to grab the sources for FreeSwitch and re-compile it that way. 
FSBASE=/usr/local/freeswitch
IPPBASE=/opt/intel/ipp/6.1.2.051/$(IPPARCH)
IPPCORE=px

CC_OPT=-fPIC -O3 -DIPPCORE_STATIC_INIT -fomit-frame-pointer -march=native -fno-exceptions
INCLUDE=-I$(IPPBASE)/include -include "$(IPPBASE)/tools/staticlib/ipp_$(IPPCORE).h" -I$(FSBASE)/include

LDFLAGS =-Wl,-static -L"$(IPPBASE)/lib" -avoid-version -module -lippscmerged -lippsrmerged -lippsmerged -lippcore -liomp5


all : decg729.o encg729.o owng729.o vadg729.o aux_tbls.o libg729.o mod_ipp_g729.o
	# -shared -Xlinker -x -lfreeswitch -pthread 
	$(CC) $(INCLUDE) $(CCMODE) -shared -O3 -Wall -Xlinker -x -o mod_ipp_g729.so  \
	   	mod_ipp_g729.o libg729.o decg729.o encg729.o owng729.o vadg729.o aux_tbls.o \
	  	-lm $(LDFLAGS) -L/usr/local/lib -Wl,-Bdynamic $(FSBASE)/lib/libfreeswitch.so -pthread -lrt -luuid -lcrypt


decg729.o : decg729.c
	$(CC) $(CC_OPT) -c decg729.c $(INCLUDE)
encg729.o : encg729.c
	$(CC) $(CC_OPT) -c encg729.c $(INCLUDE)
owng729.o : owng729.c 
	$(CC) $(CC_OPT) -c owng729.c $(INCLUDE)
vadg729.o : vadg729.c
	$(CC) $(CC_OPT) -c vadg729.c $(INCLUDE)
aux_tbls.o : aux_tbls.c
	$(CC) $(CC_OPT) -c aux_tbls.c $(INCLUDE)

libg729.o: libg729.c
	$(CC) $(CC_OPT) -c libg729.c $(INCLUDE)
mod_ipp_g729.o: mod_ipp_g729.c
	$(CC) $(CC_OPT) -c mod_ipp_g729.c $(INCLUDE)

clean:
	rm -rf *.o *.so
